package com.st.servlet;

import com.st.service.IDeptService;
import com.st.service.impl.DeptServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/emp.do")
public class EmpServlet extends BaseServlet {
	private IDeptService deptService = new DeptServiceImpl();

	public void getAll(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		List depts = deptService.getAll();
		
		request.setAttribute("depts", depts);
		request.getRequestDispatcher("dl.jsp").forward(request, response);
	}
	
	public void search(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String key = request.getParameter("key");

		List depts = deptService.search(key);
		
		request.setAttribute("depts", depts);
		request.getRequestDispatcher("dl.jsp").forward(request, response);
		
	}
}
